

									******TABLE B2*******
use "replication_dataset.dta", clear

				*1. Sex distribution
	*1.1 Sex distribution among all bac takers
tab sex

*sex	Freq.	Percent	Cum.
			
*F		333,992	54.83	54.83
*M		275,139	45.17	100.00
			
*Total	609,131	100.00

	*1.2 Sex distribution among back takers within our bandwidth
	
tab sex if within_band==1

*sex	Freq.	Percent	Cum.
			
*F		6,210	47.26	47.26
*M		6,929	52.74	100.00
			
*Total	13,139	100.00

	*1.3 Sex distribution among people in our sample

tab sex if rne==1&year!=2019	

*sex	Freq.	Percent	Cum.
			
*F	539	43.79	43.79
*M	692	56.21	100.00
			
*Total	1,231	100.00

				*2. Proportion of students in urban areas
				
		*2.1  Proportion of students in urban areas- all back takers
				
tab urban /*urban=municipiu+oras*/

*urban	Freq.	Percent	Cum.
			
*municipiu	470,926	77.32	77.32
*oras		107,474	17.65	94.97
*sat		30,641	5.03	100.00
			
*Total		609,041	100.00

		*2.2 Proportion of students in urban areas- students within bandwidth
tab urban if within_band==1 

*      urban |      Freq.     Percent        Cum.
*------------+-----------------------------------
*  municipiu |      9,751       74.21       74.21
*       oras |      2,753       20.95       95.17
*        sat |        635        4.83      100.00
*------------+-----------------------------------
*      Total |     13,139      100.00

		*2.3 Proportion of students in urban areas- students in our sample

tab urban if rne==1&year!=2019 

*      urban |      Freq.     Percent        Cum.
*------------+-----------------------------------
*  municipiu |        943       76.36       76.36
*       oras |        245       19.84       96.19
*        sat |         47        3.81      100.00
*------------+-----------------------------------
*      Total |      1,235      100.00


					*3. Proportion of students in humanities
					
		*3.1 Proportion of student in humanities-all bac takers
		
tab subject

*     subject |      Freq.     Percent        Cum.
*-------------+-----------------------------------
*hard science |    356,726       58.56       58.56
*  humanistic |    252,403       41.44      100.00
*-------------+-----------------------------------
*       Total |    609,129      100.00

		*3.2 Proportion of student in humanities-students within band
		
tab subject if within_band==1

*     subject |      Freq.     Percent        Cum.
*-------------+-----------------------------------
*hard science |      7,354       55.98       55.98
*  humanistic |      5,783       44.02      100.00
*-------------+-----------------------------------
*       Total |     13,137      100.00


		*3.3 Proportion of student in humanities-students in our sample
		
tab subject if rne==1&year!=2019 

*     subject |      Freq.     Percent        Cum.
*-------------+-----------------------------------
*hard science |        652       53.01       53.01
*  humanistic |        578       46.99      100.00
*-------------+-----------------------------------
*       Total |      1,230      100.00


					*4. Proportion of students who pass the bac
					
		*4.1 Proportion of students who pass the bac- all back takers
tab over_6

*     over_6 |      Freq.     Percent        Cum.
*------------+-----------------------------------
*          0 |    152,734       25.07       25.07
*          1 |    456,396       74.93      100.00
*------------+-----------------------------------
*      Total |    609,130      100.00

		*4.2 Proportion of students who pass the bac- students within bandwidth

tab over_6 if within_band==1

*     over_6 |      Freq.     Percent        Cum.
*------------+-----------------------------------
*          0 |      5,447       41.46       41.46
*          1 |      7,691       58.54      100.00
*------------+-----------------------------------
*      Total |     13,138      100.00

		*4.3 Proportion of students who pass the bac- students in our sample
		
tab over_6 if rne==1&year!=2019 

*     over_6 |      Freq.     Percent        Cum.
*------------+-----------------------------------
*          0 |        553       44.92       44.92
*          1 |        678       55.08      100.00
*------------+-----------------------------------
*      Total |      1,231      100.00


						**Table B3*****
		gen years_since_graduation=2019-year

gen sex2=.
replace sex2=0 if sex=="M"
replace sex2=1 if sex=="F"


reg rne over_6##sex2 over_6##c.years_since_graduation if within_band==1

*                     rne |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
*-------------------------+----------------------------------------------------------------
*                1.over_6 |  -.0149258   .0111114    -1.34   0.179    -.0367058    .0068542
*                  1.sex2 |  -.0212748    .008655    -2.46   0.014    -.0382399   -.0043098
*                         |
*             over_6#sex2 |
*                    1 1  |   .0017001   .0113038     0.15   0.880     -.020457    .0238572
*                         |
*  years_since_graduation |   .0011673   .0029354     0.40   0.691    -.0045865    .0069212
*                         |
*                  over_6#|
*c.years_since_graduation |
*                      1  |  -.0013477   .0038528    -0.35   0.726    -.0088997    .0062043
*                         |
*                   _cons |   .1321849   .0084644    15.62   0.000     .1155934    .1487764
*------------------------------------------------------------------------------------------


						*TAble B4
						
by subject, sort: tab over_6 if within_band==1 

*-> subject = hard science

*     over_6 |      Freq.     Percent        Cum.
*------------+-----------------------------------
*          0 |      3,030       41.20       41.20
*          1 |      4,324       58.80      100.00
*------------+-----------------------------------
*      Total |      7,354      100.00

*-> subject = humanistic

*     over_6 |      Freq.     Percent        Cum.
*------------+-----------------------------------
*          0 |      2,417       41.79       41.79
*          1 |      3,366       58.21      100.00
*------------+-----------------------------------
*      Total |      5,783      100.00




								***TABLE F1******


 use "WVS_Cross-National_Wave_7_Stata_v1_5.dta", clear


keep B_COUNTRY Q262 Q275 Q283 Q277 Q278 Q288 H_* G_TOWNSIZE* Q182 Q183 Q184 Q185 Q186 Q189 Q190 Q94 Q33 Q34 Q35 Q171 Q164 Q163 Q18 ///
	Q19 Q20 Q21 Q22 Q23 Q25 Q26 Q27 Q28 Q29 Q30 Q31 Q32  
	
	
	foreach var of varlist _all{
	replace `var'=. if `var'<0
	} /*recode negative values */
	


gen education=.
replace education=0 if Q275<6	
replace education=1 if Q275>=6

		****Generate the liberalism index for each country
by B_COUNTRY, sort: pca  Q182 Q183 Q184 Q185 Q186 Q189 Q190 Q94 Q33 Q34 Q35 Q171 Q164 Q163 Q18 ///
	Q19 Q20 Q21 Q22 Q23 Q25 Q26 Q27 Q28 Q29 Q30 Q31 Q32, components(1)
	
	predict pc1, score

	***standardize the pc1 variable (liberalism index)
by B_COUNTRY, sort: egen m_pc1=mean(pc1)
by B_COUNTRY, sort: egen sd_pc1=sd(pc1)
gen standard_pc1=(pc1-m_pc1)/sd_pc1

recode H_U (2=0) /*urban-rural original coding has urban=1, rural=2*/


		***The two regressions (models 1 and 2 in Table F1
		reg standard_pc1 education Q288 H_U i.Q283 Q277 Q278 i.B_COUNTRY, beta
		reg standard_pc1 education Q288 H_U i.B_COUNTRY, beta

		
									**********FIGURE F1***************

 
 
 use "WVS_Cross-National_Wave_7_Stata_v1_5.dta", clear

*keep if V242<26&V242>16 /*this is age*/


keep B_COUNTRY Q262 Q275 Q283 Q277 Q278 Q288 H_* G_TOWNSIZE* Q182 Q183 Q184 Q185 Q186 Q189 Q190 Q94 Q33 Q34 Q35 Q171 Q164 Q163 Q18 ///
	Q19 Q20 Q21 Q22 Q23 Q25 Q26 Q27 Q28 Q29 Q30 Q31 Q32  
	
	*V192 IS WRONG IN THE ORIGINAL; IT SHOULD BE V197; V12 AND V13 ARE ALSO WRONG
	*CANT FIND V48 Having a job is the best way for a woman to be independent
	*also missing voted in last election, which is also missing from 2012 WVS

*education Q275: =bachelors degree
	*negative values dropped
gen education=.
replace education=0 if Q275<6	
replace education=1 if Q275>=6


by B_COUNTRY, sort: pca  Q182 Q183 Q184 Q185 Q186 Q189 Q190 Q94 Q33 Q34 Q35 Q171 Q164 Q163 Q18 ///
	Q19 Q20 Q21 Q22 Q23 Q25 Q26 Q27 Q28 Q29 Q30 Q31 Q32, components(1)
	
	predict pc1, score

	***standardize the pc1 variable
by B_COUNTRY, sort: egen m_pc1=mean(pc1)
by B_COUNTRY, sort: egen sd_pc1=sd(pc1)
gen standard_pc1=(pc1-m_pc1)/sd_pc1

recode H_U (2=0) /*urban rural recoding*/
		
		
	
		*gen a string variable with name of country
	
	decode B_COUNTRY, gen(country)
		*the countries with names made of more than one word need changed, so that we can use the names in the code below
	replace country="United_States" if country=="United States"
	replace country="Puerto_Rico" if country=="Puerto Rico"
	replace country="South_Korea" if country=="South Korea"
	replace country="Hong_Kong" if country=="Hong Kong SAR"
	replace country="New_Zealand" if country=="New Zealand"
	replace country="ROMANIA" if country=="Romania"		
	replace country="Taiwan" if country=="Taiwan ROC"
	replace country="Macau" if country=="Macau SAR"
		
		tabulate Q283, gen(Q) /*gen 11 dummies for the categorical variable Q283, which has 12 values
								this is to facilitate the graph*/
		
		
		
		*main regression with pre-treatment covariates


	local country Myanmar Zimbabwe Tunisia China Nigeria Taiwan Nicaragua Bolivia Ecuador Colombia  ///
			Greece Ethiopia Brazil Argentina Kyrgyzstan Andorra Philippines Indonesia ROMANIA ///
			Pakistan Vietnam Australia Kazakhstan Germany Macau Serbia Malaysia Ukraine Russia ///
			Mexico Turkey Peru Cyprus Thailand Bangladesh Japan Chile
			
		
	*next are regressions by each individual country; results are stored and will be graphed later
	
	foreach x of local country {
	
	gen `x'=education
	regress standard_pc1 `x' Q2-Q12 Q277 Q278 if country=="`x'"
	estimates store `x'
	}
	
	
	**The countries made of more than one word will be done separately, to add labels to the variables created
	*these labels are the real names of the countries and will appear on the graph
	gen United_States=education
	label variable United_States "United States"
	quietly regress standard_pc1 United_States Q2-Q12 Q277 Q278 if country=="United_States"
	estimates store United_States

	gen Puerto_Rico=education
	label variable Puerto_Rico "Puerto Rico"
	quietly regress standard_pc1 Puerto_Rico Q2-Q12 Q277 Q278 if country=="Puerto_Rico"
	estimates store Puerto_Rico
	
	gen South_Korea=education
	label variable South_Korea "South Korea"
	quietly regress standard_pc1 South_Korea Q2-Q12 Q277 Q278 if country=="South_Korea"
	estimates store South_Korea
	
	gen Hong_Kong=education
	label variable Hong_Kong "Hong Kong"
	quietly regress standard_pc1 Hong_Kong Q2-Q12 Q277 Q278 if country=="Hong_Kong"
	estimates store Hong_Kong
	
	gen New_Zealand=education
	label variable New_Zealand "New Zealand"
	regress standard_pc1 New_Zealand Q2-Q12 Q277 Q278 if country=="New_Zealand"
	estimates store New_Zealand
	
	
	ssc install coefplot
	
	coefplot (Myanmar, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Zimbabwe, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Tunisia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (China, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Nigeria, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Taiwan, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Nicaragua, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Bolivia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Ecuador, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Colombia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Hong_Kong, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Greece, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Ethiopia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Brazil, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Argentina, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Kyrgyzstan, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Andorra, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Philippines, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Indonesia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (United_States, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(ROMANIA, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Pakistan, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Vietnam, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Australia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Kazakhstan, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Puerto_Rico, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Germany, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Macau, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Serbia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Malaysia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Ukraine, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Russia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(New_Zealand, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Mexico, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Turkey, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (South_Korea, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Peru, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Cyprus, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Thailand, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Bangladesh, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Japan, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Chile, mcolor(black) msize(vsmall) ciopts(lcolor(black))), ///
	drop(_cons Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10 Q11 Q12 Q277 Q278) legend(off) graphregion(color(white)) yscale(alt) xlabel(,labsize(tiny)) ylabel(,labsize(tiny)) ///
	aspectratio(2.5) xline(0, lcolor(black))
	
	
